<template>
  <div id="App">
    <MyHeader title="标题"></MyHeader>
    <component :is="componentName">
      <MyUserInfo></MyUserInfo>
      <MyGoodsSearch></MyGoodsSearch>
      <MyGoodsList></MyGoodsList>
    </component>
    <MyTabBar @editComponentName="edit" :arr='tabList'></MyTabBar>
  </div>
</template>

<script>
import MyHeader from '@/components/MyHeader'
import MyTabBar from '@/components/MyTabBar'
import MyUserInfo from '@/components/MyUserInfo'
import MyGoodsSearch from '@/components/MyGoodsSearch'
import MyGoodsList from '@/components/MyGoodsList'
export default {
  components: {
    MyHeader,
    MyTabBar,
    MyUserInfo,
    MyGoodsSearch,
    MyGoodsList
  },
  data () {
    return {
      componentName: 'MyGoodsList',
      tabList: [
        {
          iconText: 'icon-shangpinliebiao',
          text: '商品列表',
          componentName: 'MyGoodsList'
        },
        {
          iconText: 'icon-sousuo',
          text: '商品搜索',
          componentName: 'MyGoodsSearch'
        },
        {
          iconText: 'icon-user',
          text: '我的信息',
          componentName: 'MyUserInfo'
        }
      ]
    }
  },
  methods: {
    // 显示更换中间组件
    edit (index) {
      this.componentName = this.tabList[index].componentName
    }
  }
}
</script>

<style scoped>
 #App {
  padding-top: 45px;
}
</style>
